package com.panasonic.cn.cmsc;

import java.io.*;
import java.lang.*;
import java.util.*;
import java.math.*;
import java.sql.SQLException;
import com.fujitsu.fks.jaaf.core.*;

public class SQLMFLATC{
	private Hashtable paramsString     = new Hashtable();
	private Hashtable paramsBigDecimal = new Hashtable();
	private Hashtable paramsFree       = new Hashtable();
	private String lastSql_ = null;

	private String getString(String name){
		if(name==null) return "";
		String returnStr = (String)paramsString.get(name);
		if(returnStr==null) return "";
		return "'"+FrameworkCommon.stringReplaceSQuote(returnStr)+"'";
	}

	private String getBigDecimal(String name){
		if(name==null) return "";
		BigDecimal returnStr = (BigDecimal)paramsBigDecimal.get(name);
		if(returnStr==null) return "";
		return returnStr.toString();
	}

	private String getFree(String name){
		if(name==null) return "";
		String returnStr = (String)paramsFree.get(name);
		if(returnStr==null) return "";
		return returnStr;
	}

	public String getLastSql(){
		return lastSql_;
	}

	public SelectResultRset SELECT_FLATC01(FrameworkDbCommon db) throws Exception {
		StringBuffer sql = new StringBuffer();
		sql.append("	SELECT ");
		sql.append("	TRIM(NVL(FLT_CD       ,'')) AS FLT_CD       ,");
		sql.append("	TRIM(NVL(APL_BDT      ,'')) AS APL_BDT      ,");
		sql.append("	TRIM(NVL(TMP_AC_TYP   ,'')) AS TMP_AC_TYP   ,");
		sql.append("	TRIM(NVL(AC_END_DT    ,'')) AS AC_END_DT    ,");
		sql.append("	TRIM(NVL(CTRL_DVSN_CD ,'')) AS CTRL_DVSN_CD ,");
		sql.append("	TRIM(NVL(CTRL_RGN_TYP ,'')) AS CTRL_RGN_TYP ,");
		sql.append("	TRIM(NVL(TRPT_CLSS_TYP,'')) AS TRPT_CLSS_TYP,");
		sql.append("	TRIM(NVL(TRPT_ENGL_NM ,'')) AS TRPT_ENGL_NM ,");
		sql.append("	TRIM(NVL(TRPT_ENGL_AB ,'')) AS TRPT_ENGL_AB ,");
		sql.append("	TRIM(NVL(RGN_TYP      ,'')) AS RGN_TYP      ,");
		sql.append("	TRIM(NVL(CNTY_CD      ,'')) AS CNTY_CD      ,");
		sql.append("	TRIM(NVL(ADR_CD       ,'')) AS ADR_CD       ,");
		sql.append("	TRIM(NVL(PST_NO       ,'')) AS PST_NO       ,");
		sql.append("	TRIM(NVL(TRPT_ENGL_ADR,'')) AS TRPT_ENGL_ADR,");
		sql.append("	TRIM(NVL(TEL_NO       ,'')) AS TEL_NO       ,");
		sql.append("	TRIM(NVL(FAX_NO       ,'')) AS FAX_NO       ,");
		sql.append("	TRIM(NVL(TLX_NO       ,'')) AS TLX_NO       ,");
		sql.append("	TRIM(NVL(CO_CD        ,'')) AS CO_CD        ,");
		sql.append("	TRIM(NVL(P_G_CD       ,'')) AS P_G_CD       ");
		sql.append("	FROM");
		sql.append("	FLATC");
		sql.append("	WHERE");
		sql.append("	FLT_CD "+((getString("FLT_CD").equals(""))?" is null ":"=")+getString("FLT_CD")+"");
		sql.append("	AND");
		sql.append("	APL_BDT "+((getString("APL_BDT").equals(""))?" is null ":"=")+getString("APL_BDT")+"");
		db.setSql(sql.toString());
		lastSql_ =sql.toString();
		SelectResultRset srr = db.executeQuery();
		paramsString     = new Hashtable();
		paramsBigDecimal = new Hashtable();
		paramsFree       = new Hashtable();

		return srr;
	}


	public void setFLT_CD(String value){
		if(value==null) {
			paramsString.remove("FLT_CD");
			return;
		}
		paramsString.put("FLT_CD",value);
	}


	public void setAPL_BDT(String value){
		if(value==null) {
			paramsString.remove("APL_BDT");
			return;
		}
		paramsString.put("APL_BDT",value);
	}


}
